<template>
  <div class="toolbar">
    <div class="toolbar-title">
      <i class="fas fa-random"></i>
      <span>数据集处理流水线可视化系统</span>
    </div>
    <div class="toolbar-buttons">
      <button class="toolbar-btn" @click="emit('newPipeline')">
        <i class="fas fa-plus"></i>
        <span>新流水线</span>
      </button>
      <button class="toolbar-btn" @click="emit('showHistory')">
        <i class="fas fa-history"></i>
        <span>历史版本</span>
      </button>
      <button class="toolbar-btn save-btn" @click="emit('save')">
        <i class="fas fa-save"></i>
        <span>保存</span>
      </button>
      <button class="toolbar-btn execute-btn" @click="emit('execute')">
        <i class="fas fa-play"></i>
        <span>执行流水线</span>
      </button>
      <button class="toolbar-btn" @click="toggleHelp">
        <i class="fas fa-question-circle"></i>
        <span>系统说明</span>
      </button>
    </div>

    <!-- 系统说明弹出框 -->
    <div class="help-popover" v-if="showHelp">
      <div class="legend-panel">
        <div class="legend-items">
          <div class="legend-item">
            <div class="legend-icon icon-added">
              <i class="fas fa-plus"></i>
            </div>
            <div>新增字段</div>
          </div>
          <div class="legend-item">
            <div class="legend-icon icon-modified">
              <i class="fas fa-sync-alt"></i>
            </div>
            <div>修改字段</div>
          </div>
          <div class="legend-item">
            <div class="legend-icon icon-removed">
              <i class="fas fa-trash"></i>
            </div>
            <div>删除字段</div>
          </div>
          <div class="legend-item">
            <div class="legend-icon icon-split">
              <i class="fas fa-cut"></i>
            </div>
            <div>拆分操作</div>
          </div>
          <div class="legend-item">
            <div class="legend-icon icon-aggregate">
              <i class="fas fa-object-group"></i>
            </div>
            <div>聚合操作</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      showHelp: false
    };
  },
  methods: {
    emitEvent(event) {
      this.$emit(event);
    },
    toggleHelp() {
      this.showHelp = !this.showHelp;
    }
  }
};
</script>

<style scoped>
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: white;
  padding: 15px 30px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.toolbar-title {
  display: flex;
  align-items: center;
  font-size: 1.6rem;
  font-weight: 600;
}

.toolbar-title i {
  margin-right: 15px;
  font-size: 1.8rem;
  color: var(--step-1-color);
}

.toolbar-buttons {
  display: flex;
  gap: 15px;
}

.toolbar-btn {
  padding: 12px 25px;
  font-size: 1rem;
  font-weight: 500;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  cursor: pointer;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

.toolbar-btn i {
  margin-right: 10px;
  font-size: 1.2rem;
}

.save-btn {
  background: linear-gradient(135deg, #43cea2 0%, #3498db 100%);
}

.execute-btn {
  background: linear-gradient(135deg, #FF512F 0%, #F09819 100%);
}

/* ... existing styles ... */

/* 图例面板样式 */
.legend-panel {
  background: white;
  color: black;
  border-radius: 10px;
  padding: 10px;
  border: 1px solid var(--border-color);
  box-shadow: 0 3px 8px rgba(0,0,0,0.05);
}

.legend-items {
  display: flex;
  gap: 15px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.9rem;
}

.legend-icon {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: white;
}

/* 系统说明弹出框样式 */
.help-popover {
  position: absolute;
  top: 100%;
  right: 20px;
  z-index: 1000;
  background: white;
  border-radius: 8px;
  box-shadow: 0 6px 12px rgba(0,0,0,0.15);
  padding: 15px;
  min-width: 300px;
  border: 1px solid var(--border-color);
}

/* 图例面板样式 */
.legend-panel {
  background: white;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 3px 8px rgba(0,0,0,0.05);
}

.legend-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.legend-icon {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: white;
}

.icon-added { background-color: #2e7d32; }
.icon-modified { background-color: #ef6c00; }
.icon-removed { background-color: #c62828; }
.icon-split { background-color: #0288d1; }
.icon-aggregate { background-color: #7b1fa2; }
</style>
